package nx.arbitrators;

import nx.behaviors.NxBehavior;

/**
 * Base-class for all Arbiters. An arbiter should also behave as a Behavior, in
 * order to create complex behaviors. That is why it extends NxBehavior.
 *
 * @author Alejandro Pustowka, Jonathan Hernandez
 */
public abstract class Arbitrator extends NxBehavior{
    private NxBehavior[] behaviors;

    /**
     * Simple constructor
     * @param name Name of the arbiter.
     * @param behaviors The behaviors associated to this Arbiter.
     */
    public Arbitrator(String name, NxBehavior [] behaviors) {
        super(name);
        this.behaviors = behaviors;
    }

    /**
     * Simple constructor. A single behavior is used.
     * @param name Name of the arbiter.
     * @param behavior Single behavior.
     */
    public Arbitrator(String name, NxBehavior behavior) {
        
        super(name);
        behaviors = new NxBehavior[1];
        behaviors[0] = behavior;
    }

    /**
     * Get the associated behaviors of this arbiter (behavior stack).
     * @return Array of NxBehaviors.
     */
    public NxBehavior[] getBehaviors() {
        return behaviors;
    }

    /**
     * Sets the behavior stack.
     * @param behaviors Array of NxBehaviors.
     */
    public void setBehaviors(NxBehavior[] behaviors) {
        this.behaviors = behaviors;
    }
}
